package org.itli.jnsocket.Service.ServiceImpl;

import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j;
import org.itli.jnsocket.Mapper.OutBindHistoryMapper;
import org.itli.jnsocket.Pojo.Outbound;
import org.itli.jnsocket.Service.OutBindHistoryService;
import org.itli.jnsocket.Util.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class OutBindHistoryServiceImpl implements OutBindHistoryService {

    OutBindHistoryMapper mapper;

    Gson gson;

    @Autowired
    public void setMapper(OutBindHistoryMapper mapper) {
        this.mapper = mapper;
    }

    @Autowired
    public void setGson(Gson gson) {
        this.gson = gson;
    }

    @Override
    public String CardInfo(PageUtil page) {
        try{
            List<Outbound> outbounds = mapper.carInfo(page.getSize(), page.getPage());
            return gson.toJson(outbounds);
        } catch (Exception e) {
            log.info(e.getMessage());
            return "error";
        }
    }
}
